/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Bussiness;

import DAO.Customer;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author User
 */
public class CustomeTable extends AbstractTableModel {
    private static final int COLUMNS=8;
    
    List<Customer> std;
    
    public CustomeTable(List<Customer> std) {
        this.std = std;
    }
    public int getRowCount() {
        return std.size();
    }

    public int getColumnCount() {
        return COLUMNS;
    }
    @Override
    public String getColumnName(int column){
        switch(column) {
            case 0:
                    return "Ten khach hang";
            case 1:
                    return "Ma khach hang";
            case 2:
                    return "Dia chi";
            case 3:
                    return "Ngay sinh";
            case 4:
                    return "So dien thoai";
            case 5:
                    return "So tai khoan";
            case 6:
                    return "So the";
            case 7:
                    return "MaPin";
        }
        return null;
    }
    public Object getValueAt(int rowIndex, int columnIndex) {
        Customer c = std.get(rowIndex);
        switch (columnIndex){
            case 0:
                    return c.getCustomerName();
            case 1:
                    return c.getCustomerID();
            case 2:
                    return c.getAddress();
            case 3:
                    return c.getBirth();
            case 4:
                    return c.getPhoneNumber();
            case 5:
                    return c.getSotaikhoan();
            case 6:
                    return c.getSothe();
            case 7:
                    return c.getMaPin();
        }
        return null;
    }

    public void AddCustomer(Customer c){
        std.add(c);
        this.fireTableDataChanged();
    }
    public void UpdateCustomer(Customer c){
        this.fireTableDataChanged();
    }
    public void DeleteCustomer(Customer c) {
        std.remove(c);
        this.fireTableDataChanged();
    }
    public Customer getValueAt(int rowIndex) {
        return std.get(rowIndex);
    }
}
